﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;

namespace WebAop.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class uPLOADController : ControllerBase
    {
        private readonly IWebHostEnvironment web;

        public uPLOADController(IWebHostEnvironment Web)
        {
            web = Web;
        }


        [HttpPost]
         public IActionResult Uploa(IFormFile file)
        {
           string nwfamee=Guid.NewGuid().ToString();
             string path=web.WebRootPath +@"\pic\"+ nwfamee+file.FileName;
            using (FileStream fs=System.IO.File.Create(path))
            {
                 file.CopyTo(fs);
                 fs.Close();
            }
            return Ok(@"/pic/" + nwfamee + file.FileName);

        }
    }
}
